<?php
    include_once '../service/Project_Service.php';
    include_once '../service/Gallery_Service.php';

    $project        =   new Project_Service();
    $service_Gallery    = new Gallery_DAO();
    $cate_id = $_GET['id'];
    $table      =   '';
    $table2     =   '';
    $check = 0;
    $check2 = 0;
    $descript2 = 'No Description';
    $list_Project   =   $project->getList_Project($cate_id);
   $n = 1;
    foreach ($list_Project as $value){
        if($n==1){
            $list_Gallery =  $service_Gallery->getList_Gallery($value->getID(),null,null);}
        $pro_id     = $value->getID();
        $id[]       = $pro_id;
        $name[]       = $value->getPro_Name();
        $image[]    = $service_Gallery->getFirst_Gallery($pro_id);
        $descript[] =  $value->getPro_Description();
        $check=1;
        ++$n;
    }
    if($check == 1){
        foreach ($list_Gallery as $value){
                                                $image2[]    = $value->getGal_Image();
                                                $descript2      = $value->getGal_Description();
                                                $check2=1;
                                            }
    }

    
?>

    
    <div id="content_right" style="margin-top:18px;">
            <div id="content_top_left"></div>
            <div id="content_top">
                <ul class="title_content">
                    <?php
                        if($cate_id==1){
                            echo 'Kitchens';
                        }
                        if($cate_id==2){
                            echo 'Bathrooms';
                        }
                        if($cate_id==3){
                            echo 'Makeovers';
                        }
                    ?>
                </ul>
            </div>
            <div id="content_top_right"></div>
            <div class="rightButton" id="content_next"></div>
            <div id="load_gallery">
            <div id="featureCarousel">
               <?php
                                        if($check2 == 1)
                                        {
                                            
                                            $i = 0;
                                            $count_image = count($image2);
                                            while($i < $count_image)
                                            {
                                                $table2 .='<div class="feature">
                                                            <a href="#"><img alt="Image Caption" src="../uploads/gallery/'.$image2[$i].'"/></a>
                                                        </div>';
                                                ++$i;
                                            }
                                        }
                                         else {
                                                 $table2 .= '<div class="feature">
                                                                <a href="#"><img alt="Image Caption" src="../uploads/gallery/no_photo.jpg"/></a>
                                                            </div>
                                                            <div class="feature">
                                                                <a href="#"><img alt="Image Caption" src="../uploads/gallery/no_photo.jpg"/></a>
                                                            </div>
                                                            <div class="feature">
                                                                <a href="#"><img alt="Image Caption" src="../uploads/gallery/no_photo.jpg"/></a>
                                                            </div>';

                                        }
                                        echo $table2;
                                    ?>
            </div>
             <div class="pro_descript">
                <p><?php echo $descript2;?></p>
            </div>
            </div>
            <div class="leftButton" id="content_previous"></div>
            <div id="content_bottom"></div>
        </div>
<div class="clear"></div>
<div class="content_project">
          <ul id="mycarousel" class="jcarousel-skin-tango">

                    <?php
                                        if($check == 1)
                                        {

                                            $i = 0;
                                            $count_id = count($id);
                                            while($i < $count_id)
                                            {
                                                $image_new = ($image[$i] != '')?$image[$i]:'no_photo.jpg';
                                                $table .='<li><div class="project-list">
                                                        <div class="project-wrapper">
                                                            <div class="project-image">
                                                                <a onclick="getImage(\''.$id[$i].'\');"><img width="135" border="0" title="'.$descript[$i].'" alt="'.$descript[$i].'" src="../uploads/thumb/'.$image_new.'"></a>
                                                            </div>
                                                            <div class="project-title"><a style="color:#818285" onclick="getImage(\''.$id[$i].'\');">'.$name[$i].'</a></div>
                                                        </div>
                                                    </div></li>';
                                                ++$i;
                                            }
                                        }
                                        echo $table;
                                    ?>
          </ul>
        </div>